<?php
$subPage = $this->subPage;
$allCategory = $this->allCategory;
if ($subPage) {
?>
    <div>
        <h1 class="pink">Sub Categories &raquo; <?php echo @$allCategory[$subPage]['admin_title'] ?></h1>
    </div>
<?php
} else {
?>
<div>
    <h1 class="pink">Categories</h1>
</div>
<?php
} // subPage
?>
<?php
$results = $this->results;

$countTotal = count($results);
if (count($results) > 0) {
?>
    <div style="font-weight:bold;padding:10px 0px;">
        <?php echo $this->start + 1?> - <?php echo $this->start + $countTotal?> of <?php echo $this->countTotal?>
    </div>
<form action="<?php echo BASE_URL?>/category/updatefunction" id="updatefunction" method="post">
    <table width="100%">
        <thead>
            <tr>
                <td></td>
                <td>
                    <input type="checkbox" name="checkall" id="checkall">
                </td>
                <td>
                    Category
                </td>
            </tr>
        </thead>
    <?php
        $i = 1;
        foreach($results as $result):
        ?>
            <tr>
            <td width="20" <?php if ($i %2 == 0) echo "style='background:#DFDCDC'";?>>
                <?php echo $this->start + $i?>
            </td>
            <td width="20" <?php if ($i %2 == 0) echo "style='background:#DFDCDC'";?>>
                <input type="checkbox" name="deleteid[]" value="<?php echo $result['category_id']?>">
            </td>
            <td <?php if ($i %2 == 0) echo "style='background:#DFDCDC'";?>>
                <a href="<?php echo BASE_URL?>/category/detail/?id=<?php echo $result['category_id']?>"><?php echo $result['admin_title']?></a>
            </td>
            </tr>
        <?php
            $i++;
        endforeach;
    ?>
    </table>
    <input type="submit" name="delete" value="delete">
</form>
    <div style="padding:10px 0px"><?php echo $this->paging;?></div>
<?php
}
?>

		<script type="text/javascript">
		$(document).ready(function()
		{
			$("#checkall").click(function()				
			{
				var checked_status = this.checked;
				$("input[type='checkbox']").each(function()
				{
					this.checked = checked_status;
                    //console.log(this.checked);
				});
			});					
		});
		
		</script>
